home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
...taking it to the Macs!
/
...taking it to the Macs!.iso
/
Extras
/
ActiveX Mac SDK
/
ActiveX SDK
/
Common
/
CBaseCOM.cpp
next >
Wrap
Text File
|
1997-01-03
|
1KB
|
78 lines
// =================================================================================
//
// CBaseCOM.cpp ©1996 Microsoft Corporation All rights reserved.
//
// =================================================================================
#include <compobj.h>
#include <Platform.h>
#include "CRefCount.h"
#include "CBaseCOM.h"
#pragma mark === CBaseCOM::IUnknown ===
CBaseCOM::CBaseCOM(void)
{
}
CBaseCOM::~CBaseCOM(void)
{
}
//
// CBaseCOM::IUnknown::QueryInterface
//
// Returns a pointer to the specified interface on a component to which a
// client currently holds an interface pointer.
//
STDMETHODIMP
CBaseCOM::QueryInterface(REFIID inRefID, void** outObj)
{
void* pv = nil;
if ( inRefID == IID_IUnknown )
pv = (void*)(IUnknown* ) this;
*outObj = pv;
// if we got an interface, ref it and return ok
if ( pv )
{
((IUnknown*) pv)->AddRef();
return S_OK;
}
else
return E_NOINTERFACE;
}
//
// CBaseCOM::IUnknown::AddRef
//
// Increments the reference count for the calling interface.
//
STDMETHODIMP_(Uint32)
CBaseCOM::AddRef(void)
{
return ++mRefCount;
}
//
// CBaseCOM::IUnknown::Release
//
// Decrements the reference count for the calling interface on a object. If
// the reference count on the object falls to zero, the object is freed.
//
STDMETHODIMP_(Uint32)
CBaseCOM::Release(void)
{
if (--mRefCount != 0)
return mRefCount;
delete this;
return 0;
}